I apologize for posting so many related questions, but I am having difficulties getting my project to work properly. I have a function in which I am trying to simply print out the names of each module in a project. In the reference manual, I saw the "for all modules in project" section that looked to be what I wanted. However, when I try to add it to my function, I'm not getting anything. Here is my function:
void getData(DBE dbe) {
/* getData is the main function called when the user
clicks the Run button */
Project p;
Folder f;
string modName;
p = project "/Sim Stim";
infoBox("In getData");
for modName in p do
print modName "\n";
}
I thought this code looked the same as the code in the section, but when I run this, I only get the "In getData" infoBox and I don't get anything printed out to the DXL output box. Is there something wrong with the way I'm setting the variable p?
Chris Christopher Cote - Tue Apr 09 09:21:31 EDT 2019 |
Re: Looping thru modules in a project Hi Chris, the DXL manual says about the "for <string> in <Project>" loop: "This loop includes open or closed modules but only at the top level of the project. This is no longer everything contained in the project." (so, no modules in subdirectories or subprojects are printed) Perhaps you should better use the "for <item> in <Project>" loop ("Assigns itemRef to be each successive undeleted item (for which the user has read access) in project, looping recursively through contained folders and projects."):
Item i
Project p = project "/Sim Stim"
for i in p do {
if "Formal" == type i then print fullName i "\n"
}
Or if you don't want Modules of subprojects, walk recursively through the project using the "for <item> in <Folder>" loop.
Regards, |
Re: Looping thru modules in a project Google would have maybe found you this good example of looping through the DOORS database hierarchy levels:http://www.smartdxl.com/content/?p=442 |
Re: Looping thru modules in a project Thank you Mike. The item in Project will be just what I need.
Chris |